<link
	href="${rc.getContextPath()}/manage/css/dwzCustomCss/dwz.custom.css?v=${ver}"
	rel="stylesheet" type="text/css">
<style>
.searchContent>li span.error {
	float: right;
	margin: 5px 9px 0px 0px;
}
</style>
<div class="pageContent" id="jGridForUnarrangedControls"></div>
<script type="text/javascript">
	(function($) {
		var $page = DWZ.context(), $label, unarrangedOrdersProperties = {},
		dateFmt = 'yyyy-MM-dd', timeFmt = 'yyyy-MM-dd HH:mm:ss', 
		orderTypes = JSON.parse('<#noescape>${orderTypes}</#noescape>'), 
		eCodeStatus = JSON.parse('<#noescape>${eCodes}</#noescape>');

		orderTypes.unshift({
			orderTypeCode: '',
			orderTypeText: '<@label key="all.C">所有</@label>'
		});

		var $grid = $('#jGridForUnarrangedControls', $page).jGrid({
			layoutH: 135,
			width: 1400,
			base: '${rc.getContextPath()}/manage/operationArrangement/',
			url: 'getCreatedControlsByCondition',
			columns: [{
				field: 'productionOrderNum;productionControlNum',
				group: 'orderNums',
				type: 'checkbox',
				width: 22
			}, {
				field: '_index',
				text: '<@label key="serialNumber.C">序号</@label>',
				width: 40
			}, {
				field: 'productionControlNum',
				text: '<@label key="productionControlNum.C">生产管理号</@label>',
				width: 100
			},{
				field: 'statuseCode',
				text: '<@label key="controlStatus.C">管理号状态</@label>',
				width: 60,
				transform: function(data) {
					var text = data;
					$.each(eCodeStatus, function() {
						if (this.eCode == data) {
							text = this.eCodeText;
							return false;
						}
					});
					return text;
				}
			}, {
				field: 'materialCode',
				text: '<@label key="materialCode.C">物料编号</@label>',
				width: 100,
				orderTable: 'o'
			}, {
				field: 'materialText',
				text: '<@label key="materialName.C">物料名称</@label>',
				width: 100
			}, {
				field: 'processCode',
				text: '<@label key="cmprocess_code.C">工艺编号</@label>',
				width: 80,
				orderTable: 'o'
			}, {
				field: 'processRev',
				text: '<@label key="cmprocessrev.C">工艺版本</@label>',
				width: 80
			}, {
				field: 'plannedQuantity',
				text: '<@label key="plannedQuantity.C">计划数量</@label>',
				width: 60
			}, {
				field: 'requirementDate',
				type: 'date',
				format: dateFmt,
				text: '<@label key="requirementDate.C">需求日期</@label>',
				width: 60,
				orderTable: 'o',
				defaultOrder: 'asc'
			}, {
				field: 'productionlotNum',
				text: '<@label key="productionlotNum.C">生产批次号</@label>',
				width: 60
			}, {
				field: 'plannedstartDateTime',
				type: 'date',
				format: timeFmt,
				text: '<@label key="plannedstartDateTime.C">计划开始时间</@label>',
				width: 120
			}, {
				field: 'plannedendDateTime',
				type: 'date',
				format: timeFmt,
				text: '<@label key="plannedendDateTime.C">计划结束时间</@label>',
				width: 120
			}],
			getQueryData: function() {
				return {};
			},
			query: {
				queryfields: [{
					field: 'orderTypeCode',
					text: '<@label key="orderType.C">订单类型</@label>',
					type: 'select',
					options: orderTypes,
					value: 'orderTypeCode',
					label: 'orderTypeText',
					render: function($select) {
						var orderType = '${orderType!""}';
						if (orderType) {
							$('>option[value=' + orderType + ']', $select).attr({
								selected: true
							});
						}
					}
				}, {
					field: 'minRequirementDate',
					type: 'date',
					format: timeFmt,
					value: '${startDate}',
					text: '<@label key="requirementStartDate.C">需求日期从</@label>',
					dateGroup: 'requirementDate',
					css: 'from'
				}, {
					field: 'maxRequirementDate',
					type: 'date',
					format: timeFmt,
					value: '${endDate}',
					text: '<@label key="EndtTime.C">到</@label>',
					dateGroup: 'requirementDate',
					css: 'to'
				}]
			},
			gridbars: [{
				icon: 'test',
				text: '<@label key="arrange.C">排产</@label>',
				target: 'selectedTodo',
				data: {
					navTabId: "${navTabId}",
					orderNums: "{orderNums}"
				},
				action: function(data) {
					var url = '${rc.getContextPath()}/manage/operationArrangement/operationArrangement_list_page';
					if (data.orderNums) {
						var groupNums = data.orderNums.split(','), orderNums = [], controlNums = [];
						for ( var index in groupNums) {
							var goupNum = groupNums[index];
							if (orderNums.indexOf(goupNum.split(';')[0]) < 0) {
								orderNums.push(goupNum.split(';')[0]);
							}
							controlNums.push(goupNum.split(';')[1]);
						}
						data.orderNums = orderNums.join(',');
						data.controlNums = controlNums.join(',');
					}
					navTab.openTab('${navTabId}', url, {
						data: $.extend(true, data, {
							startDate: unarrangedOrdersProperties.startDate,
							endDate: unarrangedOrdersProperties.endDate,
							orderType: unarrangedOrdersProperties.orderType
						}),
						title: '<@label key="operationArrange.C">工序排产</@label>',
						fresh: true,
						external: false
					});
				}
			}],
			loadcomplete: function(json) {
				unarrangedOrdersProperties.startDate = json.minRequirementDate || '';
				unarrangedOrdersProperties.endDate = json.maxRequirementDate || '';
				unarrangedOrdersProperties.orderType = json.orderTypeCode || '';
			}
		});
	})(jQuery);
</script>